﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SedCup.Code.Model;

namespace SedCup.Code.View.Components
{
    public partial class PanelTask : UserControl
    {
        #region Types

        public enum Language
        {
            CPP, CSHARP, JAVA
        }

        public enum State
        {
            TODO, INPROGRESS, DONE
        }

        #endregion Types

        #region Properties
        private int fullTime;

        public int FullTime
        {
            get { return fullTime; }
            set { fullTime = value; this.UpdatePanel(); }
        }
        

        private int timeLeft;
        /// <summary>
        /// Hátralévő idő
        /// </summary>
        public int TimeLeft
        {
            get { return timeLeft; }
            set { timeLeft = value; this.UpdatePanel(); }
        }

        private int price;
        /// <summary>
        /// A munka értéke
        /// </summary>
        public int Price
        {
            get { return price; }
            set { price = value; this.UpdatePanel(); }
        }

        private int penalty;
        /// <summary>
        /// Büntetés értéke, ha félbehagyják
        /// </summary>
        public int Penalty
        {
            get { return penalty; }
            set { penalty = value; this.UpdatePanel(); }
        }

        private Language proglang;
        /// <summary>
        /// A feladat programozási nyelve
        /// </summary>
        public Language ProgLang
        {
            get { return proglang; }
            set { proglang = value; this.UpdatePanel(); }
        }

        private State taskState;
        /// <summary>
        /// The state of completion for this task
        /// </summary>
        public State TaskState
        {
            get { return taskState; }
            set { taskState = value; this.UpdatePanel(); }
        }
        #endregion Properties

        /// <summary>
        /// 
        /// </summary>
        public PanelTask()
        {
            InitializeComponent();

            this.BackColor = Settings.GUI_BACKCOLOR_FIELD;
        }

        /// <summary>
        /// Frissíti a panelt, hogy az új adatokat mutassa
        /// </summary>
        public void UpdatePanel()
        {
            this.labelTimeLeft.Text = timeLeft.ToString() + " / " + fullTime.ToString();
            this.labelValue.Text = price.ToString() + " fb";
            this.labelPenalty.Text = penalty.ToString() + " fb";

            switch (proglang)
            {
                case Language.CPP:
                    this.toolTip.SetToolTip(this.pictureBoxLanguage, "Nyelv: C++");
                    this.pictureBoxLanguage.BackgroundImage = global::SedCup.Properties.Resources.c__;
                    break;
                case Language.CSHARP:
                    this.toolTip.SetToolTip(this.pictureBoxLanguage, "Nyelv: C#");
                    this.pictureBoxLanguage.BackgroundImage = global::SedCup.Properties.Resources.csharp;
                    break;
                case Language.JAVA:
                    this.toolTip.SetToolTip(this.pictureBoxLanguage, "Nyelv: Java");
                    this.pictureBoxLanguage.BackgroundImage = global::SedCup.Properties.Resources.java;
                    break;
            }

            switch (taskState)
            {
                case State.TODO:
                    this.toolTip.SetToolTip(this.pictureBoxState, "Elvégzendő");
                    this.pictureBoxState.BackgroundImage = global::SedCup.Properties.Resources.todo;
                    break;
                case State.INPROGRESS:
                    this.toolTip.SetToolTip(this.pictureBoxState, "Folyamatban");
                    this.pictureBoxState.BackgroundImage = global::SedCup.Properties.Resources.progress;
                    break;
                case State.DONE:
                    this.toolTip.SetToolTip(this.pictureBoxState, "Kész");
                    this.pictureBoxState.BackgroundImage = global::SedCup.Properties.Resources.done;
                    break;
            }
        }
    }
}
